package xtgl;

import xtgl.Log;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

public class LogController extends Controller {
	
	public static int pagen=10;
	public static String cxlx="";												//查询的类型
	public static String cxz="";												//查询的值
	public static String begintime="";											//起始查询时间
	public static String endtime="";											//终止查询时间

	public void index() {
		pagen=10;
		cxlx="";
		cxz="";
		begintime="";
		endtime="";
		setAttr("list", Log.dao.getlogs());
		render("/xtgl/rzgl.html");
	}

	public void pagedemo() {
		int n = getParaToInt("pageNumber");
		if(cxlx!=""&&cxz!=""&&begintime!=""&&endtime!=""){
			Page<Log> list = Log.dao.paginate(n, pagen,"select *", "from log where operation_time between'" + begintime + "' and '" + endtime + "' and " + cxlx +" like '%"+ cxz+"%' ");
			renderJson(list);
		}else if (cxlx!=""&&cxz!=""&&begintime==""&&endtime=="") {
			Page<Log> list = Log.dao.paginate(n, pagen,"select *", "from log where " + cxlx +" like '%"+ cxz+"%' ");
			renderJson(list);
		}else if (cxz==""&&begintime!=""&&endtime!="") {
			Page<Log> list = Log.dao.paginate(n, pagen,"select *", "from log where operation_time between'" + begintime + "' and '" + endtime + "'");
			renderJson(list);
		}else {
			Page<Log> list = Log.dao.paginate(n, pagen, "select *", "from log");
			renderJson(list);
		}
		
		
	}

	
	public void sele() {
		begintime=getPara("begintime");
		endtime=getPara("endtime");
		cxlx=getPara("seletype");
		cxz=getPara("selevalue");
		renderNull();

	}
	
	//更改每一页显示的行数
		public void gghs(){
			pagen=getParaToInt("pagen");
			renderText("success");
		}


}
